package com.xyz.study.spring.event;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;


/**
 * TestSpringEventListener
 *
 * @author xyz
 * @version 1.0.0
 * @since 2021/7/23
 */
@Component
public class TestSpringEventListener implements ApplicationListener<TestSpringEvent> {

    private static Logger logger = LoggerFactory.getLogger(TestSpringEventListener.class);

    @Override
    @Async
    public void onApplicationEvent(TestSpringEvent testSpringEvent) {
        TestSpringEvent.EventData eventData = testSpringEvent.getEventData();
        logger.info("-- " + eventData.getEventId() + ":" + eventData.getName());
    }
}
